package com.example.spindrift.Controllers;

import com.example.spindrift.models.SysSong;
import com.example.spindrift.service.ShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Share")
public class ShareController{
    @Autowired
    ShareService shareService;

    /**
     * 获取指定用户分享的音乐信息
     * @param userId 用户ID
     * @return
     */
    @GetMapping("/getShareSongByUser")
    public List<SysSong> getShareSong(@RequestParam Integer userId) {
        return shareService.getShareSongByUser(userId);
    }

    /**
     * 删除一条或多条分享信息
     * @param userId 用户ID
     * @param songIds 歌曲ID
     * @return
     */
    @DeleteMapping("/deleteShareSongByIds")
    public Integer deleteShareSong(@RequestParam Integer userId, @RequestParam String songIds) {
        return shareService.deleteShareSongByIds(userId,songIds);
    }

    /**
     * 搜索个人分享音乐信息
     * @param userId 用户ID
     * @param keyword 歌曲名称搜索关键字
     * @return
     */
    @GetMapping("/searchShare")
    public List<SysSong> searchShare(@RequestParam Integer userId,@RequestParam String keyword){
        return shareService.searchShare(userId,keyword);
    }
}
